package fh.bsys.threading.app;

import fh.bsys.threading.classes.Testtable;

/**
 * Testclass synchronized testtable.
 * gets the next free cell of the Testtable and writes the name 
 * of the TestClass to the Testtable.
 * @author muetze
 *
 */
public class TestClass implements Runnable {

	String name;
	
	public TestClass (String name) {
		this.name = name;
	}
	
	@Override
	public void run() {
		Testtable tt = Testtable.getInstance();
		int cell;
		while((cell = tt.getNextCell()) >= 0) {
			tt.write(new String(name), cell);
			try {
				Thread.sleep(5);
			}
			catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}

}
